/**
 * 定时任务
 */
import { getShopDetailInfo, getBankPrice } from '../services/task.js'

import { scheduleJob } from 'node-schedule'
import dayjs from 'dayjs'

export const initTasks = () => {
  const rules = `0 0 0 * * *`

  // 每天下午3点执行定时任务
  const rules2 = `0 30 15 * * *`

  scheduleJob(rules, () => {
    console.log('开始执行定时任务: ', dayjs().format('YYYY-MM-DD HH:mm:ss'));
    getShopDetailInfo()
    getBankPrice()
  })

  scheduleJob(rules2, () => {
    console.log('开始执行定时任务: ', dayjs().format('YYYY-MM-DD HH:mm:ss'));
    getShopDetailInfo()
    getBankPrice()
  })
}
